import java.util.Scanner;

public class BigShu {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数");
        int i = sc.nextInt();
        System.out.println("请输入一个数");
        int j = sc.nextInt();
        int sum = 0;
        while ((i % j) != 0) {
            sum = i % j;
            i = j;
            j = sum;
        }
        System.out.println(sum);
    }
}
